package com.wkhyapp.lm.contract;

import com.wkhyapp.lm.base.BasePresenter;
import com.wkhyapp.lm.http.ApiCallback;
import com.wkhyapp.lm.http.net.FansListRequest;
import com.wkhyapp.lm.http.net.GoodsInfoRequest;
import com.wkhyapp.lm.http.net.GoodsListRequest;
import com.wkhyapp.lm.http.net.SuperResponse;
import com.wkhyapp.lm.http.vo.Goods;
import com.wkhyapp.lm.utils.MemberUtils;

/**
 * Created by Administrator on 2021-10-8.
 */

public class CollectionPresenter extends BasePresenter<CollectionView> {

    public CollectionPresenter(CollectionView collectionView) {
        super(collectionView);
    }

    public void getData(){
        FansListRequest request = new FansListRequest();
        request.setUserId(MemberUtils.getUid());
        request.setPageNo(1);
        request.setPageSize(12);
        addSubscription(apiStores.collection(request),new ApiCallback<SuperResponse<Goods>>() {
            @Override
            public void onSuccess(SuperResponse<Goods> response) {
                mvpView.setGoods(response.getItems());
            }
            @Override
            public void onFailure(String msg) {
            }

            @Override
            public void onFinish() {
                mvpView.dismissLoad();
            }
        });

    }

    public void getDataMore(int pageNo){
        FansListRequest request = new FansListRequest();
        request.setUserId(MemberUtils.getUid());
        request.setPageNo(pageNo);
        request.setPageSize(12);
        addSubscription(apiStores.collection(request),new ApiCallback<SuperResponse<Goods>>() {
            @Override
            public void onSuccess(SuperResponse<Goods> response) {
                mvpView.setGoodsMore(response.getItems());
            }
            @Override
            public void onFailure(String msg) {
            }

            @Override
            public void onFinish() {
                mvpView.dismissLoad();
            }
        });
    }

    public void del(Long goodsId){
        GoodsInfoRequest request = new GoodsInfoRequest();
        request.setUserId(MemberUtils.getUid());
        request.setGoodsId(goodsId);
        addSubscription(apiStores.delCollection(request),new ApiCallback<SuperResponse<String>>() {
            @Override
            public void onSuccess(SuperResponse<String> response) {
                mvpView.succ();
            }
            @Override
            public void onFailure(String msg) {
            }

            @Override
            public void onFinish() {
                mvpView.dismissLoad();
            }
        });
    }


}
